define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'score/log/index' + location.search,
                    multi_url: 'score/log/multi',
                    shareuser_url: 'share/user/index',//跳转到用户列表
                    import_url: 'score/log/import',
                    table: 'score_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user_id', title: __('User_id')},
                        // {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        // {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
                        //

                        {field: 'user.username', title:__('User.username'),operate:'LIKE',visible: false},
                        {field: 'user.username_xing', title: __('User.username'), operate:false},
                        {field: 'user.mobile', title:  __('User.mobile'),operate:'LIKE',visible: false},
                        {field: 'user.mobile_xing', title: __('User.mobile'), operate:false},



                        {field: 'score', title: __('Score'), operate: false},
                        {field: 'before', title: __('Before'), operate: false},
                        {field: 'after', title: __('After'), operate: false},
                        {field: 'memo', title: __('Memo'), operate: 'LIKE'},
                        {field: 'mobile', title: __('对方信息'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: '操作', table: table,
                            //events: Table.api.events.addtabs,
                            buttons: [
                                {
                                    name: 'shareuser',
                                    text: __('用户'),
                                    // icon: 'fa fa-list',
                                    classname: 'btn btn-info btn-xs btn-detail btn-dialog',
                                    url: 'share/user/index?user_id={user_id}',
                                    refresh: true,
                                    visible:function(row){
                                        if((1==1)){
                                            return true;
                                        }else{
                                            return false;
                                        }
                                    }

                                }
                            ],
                            formatter: Table.api.formatter.operate
                        },
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
    };
    return Controller;
});
